﻿using DevExpress.XtraCharts.Native;
using DevExpress.XtraExport.Implementation;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports;
using DevExpress.XtraReports.UI;
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;

namespace BlazorApp2.Data
{
    public partial class Report1 : DevExpress.XtraReports.UI.XtraReport
    {
        public Report1()
        {
            InitializeComponent();
        }
        public string ca = string.Empty;
        private void Report1_BeforePrint(object sender, CancelEventArgs e)
        {

            xrTableCell7.Text= ca;
            XRTable baseTable = xrTable1;
            XRTableRow haBaseRow = baseTable.Rows[0];
            baseTable.Rows.Remove(haBaseRow);
            List<string> list = new() { "cs", "cs1", "cs2", "cs3", "cs4", "cs5" };
            list.AddRange(list);
            list.AddRange(list);
            list.AddRange(list);
            list.AddRange(list);
            list.AddRange(list);


            string Strde = string.Empty;
            int count = 0;
            list = list.OrderBy(x => x).ToList();
            foreach (var item in list)
            {
                XRTableRow haRow = new();
                XRTableCell haCell2 = new();

                if (!item.Equals(Strde))
                {
                    Strde = item;

                    haCell2.Text = item;
                    haCell2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                    count = list.Count(d => d == Strde);

                    haCell2.RowSpan = count;


                }
                haCell2.WidthF = haBaseRow.Cells[0].WidthF;
                haCell2.Font = new Font("宋体", 9);
                haCell2.Padding = new PaddingInfo(5, 0, 2, 2);
                haRow.Cells.Add(haCell2);

                XRTableCell haCell3 = new()
                {
                    WidthF = haBaseRow.Cells[1].WidthF,
                    Font = new Font("宋体", 9),
                    Padding = new PaddingInfo(5, 0, 2, 2),
                    HeightF = haBaseRow.Cells[1].HeightF
                };
                haRow.Cells.Add(haCell3);


                XRTableCell haCell4 = new()
                {
                    Text = "cs",
                    WidthF = haBaseRow.Cells[2].WidthF,
                    HeightF = haBaseRow.Cells[2].HeightF,
                    TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft,

                    Font = new Font("宋体", 9),
                    Padding = new PaddingInfo(5, 0, 2, 2),
                };
                haRow.Cells.Add(haCell4);


                baseTable.Rows.Add(haRow);
            }
            int totalPages = PrintingSystem.Document.PageCount;
        }

        private void Report1_FillEmptySpace(object sender, BandEventArgs e)
        {
            int totalPages = PrintingSystem.Document.PageCount;

        }
    }
}
